﻿<DockPanel  x:Class="DrawTools.IconEditor"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:lib="clr-namespace:DrawToolsLib;assembly=DrawToolsLib"
    xmlns:forms="clr-namespace:ICSharpCode.TextEditor;assembly=ICSharpCode.TextEditor"
    xmlns:libconvert="clr-namespace:Petzold.Converters;assembly=Utilities" >


    <DockPanel.Resources>

        <CommandBinding x:Key="bindUndo" Command="ApplicationCommands.Undo" 
            Executed="UndoCommand_Executed" CanExecute="UndoCommand_CanExecute" />
        <CommandBinding x:Key="bindRedo" Command="ApplicationCommands.Redo" 
            Executed="RedoCommand_Executed" CanExecute="RedoCommand_CanExecute" />

        <CommandBinding x:Key="bindTool" Command="MediaCommands.Select" Executed="SelectTool_Executed" />
        <!-- Converts double to decimal with given precision -->
        <libconvert:DoubleToDecimalConverter x:Key="convDoubleDecimal" />
    </DockPanel.Resources>

    <DockPanel.CommandBindings>
        <StaticResource ResourceKey="bindUndo" />
        <StaticResource ResourceKey="bindRedo" />
    </DockPanel.CommandBindings>

    <TabControl  Background="#00000000" BorderBrush="#FF000000" x:Name="TopTab"  TabStripPlacement="Bottom" DockPanel.Dock="Top" SelectionChanged="TopTab_SelectionChanged">

        <TabItem x:Name="TabEditor" Header="Editor">
        	<DockPanel>
        		<Label Width="35" Foreground="#FFFFFFFF" Height="25" DockPanel.Dock="Bottom" Margin="0,0,120,-30" HorizontalAlignment="Right"
        			Content="{Binding Path=Value, Converter={StaticResource convDoubleDecimal}, ConverterParameter=2, ElementName=sliderScale, Mode=OneWay}"  />
        		<Slider x:Name="sliderScale" Orientation="Horizontal" Minimum="0.25" Maximum="4" Value="2.0"
        			Width="120" Height="24" Margin="0,0,0,-33" DockPanel.Dock="Bottom" HorizontalAlignment="Right" />
        		<ScrollViewer Focusable="False" SnapsToDevicePixels="True"
        			VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" 
        			HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" DockPanel.Dock="Top">

        			<lib:DrawingCanvas x:Name="drawingCanvas" Background="#FF515151" 
        				Width="200" Height="200" 
        				ActualScale="{Binding Path=Value, ElementName=sliderScale, Mode=OneWay}" HorizontalAlignment="Center" VerticalAlignment="Center">
        				<lib:DrawingCanvas.LayoutTransform>
        					<TransformGroup>
        						<ScaleTransform 
        							ScaleX="{Binding Path=Value, ElementName=sliderScale, Mode=OneWay}" 
        							ScaleY="{Binding Path=Value, ElementName=sliderScale, Mode=OneWay}"/>
        					</TransformGroup>
        				</lib:DrawingCanvas.LayoutTransform>
        			</lib:DrawingCanvas>

        		</ScrollViewer>

        	</DockPanel>
        </TabItem>

        <TabItem x:Name="TabModel" Header="Model">
            <ScrollViewer>
                <TextBlock x:Name="InputText" Background="#FF313131" Foreground="#FFCCCCCC"
            				TextWrapping="Wrap" DockPanel.Dock="Top" ><Run Text="Model Editor would be here."/></TextBlock>
            </ScrollViewer>
        </TabItem>

        <TabItem x:Name="TabSource" Header="Source">
            <WindowsFormsHost>
                <forms:TextEditorControl x:Name="textEditor"/>
            </WindowsFormsHost>
        </TabItem>

    </TabControl>

</DockPanel>